package 你能回答这些问题吗;

import java.io.*;
import java.util.*;

public class Main {
    static int N = 500010, n, m;
    static int[] w = new int[N];
    static Node[] tr = new Node[4 * N];

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] s = in.readLine().split(" ");
        n = Integer.parseInt(s[0]);
        m = Integer.parseInt(s[1]);
        String[] str = in.readLine().split(" ");
        for (int i = 1; i <= n; i++) {
            w[i] = Integer.parseInt(str[i - 1]);
        }
        build(1, 1, n);
        while (m-- > 0) {
            String[] s1 = in.readLine().split(" ");
            int k = Integer.parseInt(s1[0]);
            int x = Integer.parseInt(s1[1]);
            int y = Integer.parseInt(s1[2]);
            if (k == 1) {
                if (x > y) {
                    int t = y;
                    y = x;
                    x = t;
                }
                out.write(query(1, x, y).tsum + "\n");
            } else {
                modify(1, x, y);
            }
        }
        out.flush();
    }

    private static void modify(int u, int x, int v) {
        if (tr[u].l == x && tr[u].r == x) {
            tr[u].tsum = v;
            tr[u].lsum = v;
            tr[u].rsum = v;
            tr[u].sum = v;
        } else {
            int mid = tr[u].l + tr[u].r >> 1;
            if (x <= mid) {
                modify(u << 1, x, v);
            } else {
                modify(u << 1 | 1, x, v);
            }
            pushup(u);
        }
    }

    private static Node query(int u, int l, int r) {
        if (tr[u].l >= l && tr[u].r <= r) {
            return tr[u];
        }
        int mid = tr[u].l + tr[u].r >> 1;
        if (r <= mid) {
            return query(u << 1, l, r);
        } else if (l >= mid + 1) {
            return query(u << 1 | 1, l, r);
        } else {
            Node ret = new Node();
            Node ret1 = query(u << 1, l, r);
            Node ret2 = query(u << 1 | 1, l, r);
            pushup(ret, ret1, ret2);
            return ret;
        }
    }

    private static void build(int u, int l, int r) {
        if (l == r) {
            tr[u] = new Node(l, r, w[l], w[l], w[l], w[l]);
        } else {
            tr[u] = new Node(l, r);
            int mid = l + r >> 1;
            build(u << 1, l, mid);
            build(u << 1 | 1, mid + 1, r);
            pushup(u);
        }
    }

    private static void pushup(Node root, Node lnode, Node rnode) {
        root.tsum = Math.max(Math.max(lnode.tsum, rnode.tsum), lnode.rsum + rnode.lsum);
        root.lsum = Math.max(lnode.lsum, lnode.sum + rnode.lsum);
        root.rsum = Math.max(rnode.rsum, rnode.sum + lnode.rsum);
        root.sum = lnode.sum + rnode.sum;
    }

    private static void pushup(int u) {
        pushup(tr[u], tr[u << 1], tr[u << 1 | 1]);
    }
}

class Node {
    int l, r, tsum, lsum, rsum, sum;

    public Node() {

    }

    public Node(int l, int r) {
        this.l = l;
        this.r = r;
    }

    public Node(int l, int r, int tsum, int lsum, int rsum, int sum) {
        this.l = l;
        this.r = r;
        this.tsum = tsum;
        this.lsum = lsum;
        this.rsum = rsum;
        this.sum = sum;
    }
}